 
 *******************
* Exporting table for Global South COVID paper
* 2020-06-13
* last updated: 2020-09-09
* Magdalena Larreboure
*******************

set more off
gl weight hh_weight
use "$da/KEN3_maintable.dta" , clear

//drop if inlist(s2_q9a_county, 10, 28, 31, 25, 30, 23, 24) // Marsabit, Elgeyo-Marakwet, Laikipia, Samburu, Baringo, Turkana and West Pokot are ranked at ‘very high risk’ re: locusts.


loc outcomes inc3_total_drop employmentdrop healthaccess missedmeals anysupport 


********************************************************************************************************
********************************************************************************************************
********************************************************************************************************

local sR *
local sig1 `sR'
local sig2 `sR'`sR'
local sig3 `sR'`sR'`sR'
local formatDisp %10.2f

	
*Complete sample
	foreach var of varlist `outcomes' {
	qui sum `var' [aw=$weight]
	loc mpost=`r(mean)'
	loc mpost_`var'_all1:  di %10.2fc r(mean)
	loc `var'_SD :  di %10.2fc r(sd)
	loc sdpr_`var'_all1 "(``var'_SD')"
	loc n_`var'_all1:  di %10.0fc r(N)
	
*Heterogeneity dimensions
	
	foreach het in "b_inc" { 
	forval i=0/1 {
	qui sum `var' [aw=$weight] if `het'==`i'
	loc mpost=`r(mean)'
	loc mpost_`var'_`het'`i':  di %10.2fc r(mean)
	loc `var'_SD :  di %10.2fc r(sd)
	loc sdpr_`var'_`het'`i' "(``var'_SD')"
	loc n_`var'_`het'`i':  di %10.0fc r(N)

	}
	}
	}
		

	clear all
	set obs 3
	
	g full_sample=0
	replace full_sample = 1 in 1
	g below_income=0
	replace below_income = 1 in 2
	g above_income=0
	replace above_income = 1 in 3

	
	foreach var in "inc3_total_drop" "employmentdrop" "accessmarkets" "healthaccess" "missedmeals" "anysupport" { 

		g post_`var'   = ""	
			
	
			replace post_`var'   = "`mpost_`var'_b_inc1'" if below_income==1
			replace post_`var'   = "`mpost_`var'_b_inc0'" if above_income==1
			replace post_`var'   = "`mpost_`var'_all1'" if full_sample==1
	
	}
	
		g n=""
		replace n = "`n_anysupport_all1'" in 1
		replace n = "`n_anysupport_b_inc1'" in 2
		replace n = "`n_anysupport_b_inc0'" in 3

	
	drop below_income above_income full_sample
 	export excel using "$dtab/Main Table (empty).xlsx", sheetmodify cell(B40)
